home *** CD-ROM | disk | FTP | other *** search
/ Die Speccy' 97 / Die Speccy' 97.iso / amiga_system / the_aminet / util / shell / smartfiles.lha / SmartDOS.txt < prev   
Text File  |  1995-09-30  |  5KB  |  129 lines

  1.  
  2.   Okay, you've got a directory full of files, and you want to do the same
  3. operation to each of them.  Some examples might be:
  4.  
  5. > Editing a number of textfiles, then doing something to each of them after
  6. you're through, such as renaming them or copying a duplicate to a different
  7. directory.
  8.  
  9. > Compressing a number of files to individual LZX files.
  10.  
  11. > Converting other archives to LZX, the first of the "smart" archivers.
  12.  
  13. > Adding a ReadMe file or something to a number of LZX files.
  14.  
  15. Really, any operation that you can list out as a standard Execute scriptfile,
  16. but this will allow you to do it to a large random number of files, rather
  17. than some specified list.
  18.  
  19.  
  20.   Let's take an easy example:  Let's say we have a bunch of pictures we want
  21. to compress to individual LZX files.  They're in our dh0:Files directory.
  22.   
  23.   Smart DOS uses the List command to list out the Files directory, and the
  24. "LFORMAT" option lists out a separate command line for each one.  The
  25. "<name>" wildcard will be the name of the next file on the list.  If we were
  26. making an Execute scriptfile, planning on doing this to just ONE file, it
  27. would look something like the following.  This could be done better, but for
  28. this example we'll just take it step-by-step:
  29.  
  30.  
  31.   MakeDir Ram:Temp                ;we'll do all the work here
  32.   CD Ram:Temp
  33.  
  34.   Copy dh0:Files/<name> Ram:Temp  ;copies the file to Ram:Temp
  35.   LZX a <name>                    ;compresses the file to <name>.LZX
  36.   Copy <name>.LZX dh0:Files       ;copies new LZX file back to hard drive
  37.   Delete #?                       ;deletes files in work area
  38.  
  39.  
  40.   Okay, with me so far?  Now check out the following.  To note is that the 
  41. Echo line is ONE line with your text editor, although it'll break into two 
  42. lines here.  This is a scriptfile that you Execute:
  43.  
  44. ----------------------
  45.  
  46. .k dev                    ;don't put anything above these four lines
  47. .def dev "Ram:"       
  48. .bra {                
  49. .ket }
  50.  
  51. MakeDir Ram:Temp
  52. CD Ram:Temp
  53.  
  54. List >Ram:x1 dh0:Files nohead quick LFORMAT "Execute Ram:x2 %s %s"
  55.  
  56. Echo >Ram:x2 ".k path,name*nCopy dh0:Files/<name> Ram:Temp*nLZX a <name>*n-
  57. Copy <name>.LZX dh0:Files*nDelete #?"
  58.  
  59. Execute Ram:x1             ;this is what actually does the work
  60.  
  61. ---------------------------
  62.  
  63.   Okay, you can kinda see what that did.  It listed out the files in
  64. dh0:Files, it kept the list `clean' with nohead and quick, and the LFORMAT
  65. puts the Echo line before each entry, with the whole mess being outputted to
  66. a scriptfile in Ram called x1 which is then Executed to do the actual work.
  67.  
  68.   The Echo command is ONE line, remember.  It should basically be what we had
  69. listed up above, with the little "*n" jobbies in between each command.  I
  70. guess the line can be as long as 255 characters, the max width of a DOS line.
  71. If you need it to be longer, I suppose you'd Execute sub-scriptfiles.
  72. Whether or not the sub-scripts would understand the "<name>" wildcard, I
  73. don't know.  But they "should".  <chuckle>
  74.  
  75.   The next improvement we make is using some generic directory heading for
  76. the directory the files are in, like "XXX:".  We "Assign dh0:Files: XXX:"
  77. before running the scriptfile.  This way we don't have to keep altering the
  78. file.  If the next directory of files to be worked on is "dh0:Files2", then
  79. just Assign that to "XXX:" before Executing the file again.
  80.  
  81.   So now it looks like this:
  82.  
  83. List >Ram:x1 XXX: nohead quick LFORMAT "Execute Ram:x2 %s %s"
  84.  
  85. Echo >Ram:x2 ".k path,name*nCopy XXX:<name> Ram:Temp*nLZX a <name>*n-
  86. Copy <name>.LZX XXX:*nDelete #?"
  87.  
  88.   That does the same thing as our original example, only now we can leave the
  89. scriptfile alone and just Assign whatever dir that needs work to "XXX:".
  90.  
  91.  
  92.   Following is an example of how to use sub-directories in all this, like if
  93. you're LZX'ing directories and sub-directories.  This converted my LHA files
  94. to LZX.  The LHA archives are in "XXX:", the path for the new LZX files is
  95. "YYY:".  
  96.  
  97. Note:  I use the old arp version of Copy as it handles wildcards better.
  98.  
  99. First, let's list them out so it'll look understandable:
  100.  
  101. LHA x XXX:<path><name>                ; extracts files from archive
  102. LZX -3 -m -r -x -e -Y a <name> #?     ; LZX does its thing
  103. copy #?.LHA.LZX YYY:#?.LZX            ; copies new LZX file to YYY:
  104. delete #? all"                        ; deletes everything in work area
  105.  
  106.   What you're noting are the "<path><name>" commands, the extended string for
  107. LZX, the "all" in "delete all" (to get any sub-dirs), and how "<name>" is
  108. going to be something like "BOOBIES.LHA", so when you LZX the "<name>", the
  109. LZX filename is going to be "BOOBIES.LHA.LZX".  That's why the odd look to
  110. the copy command.  You can try your own Copy command, just keep the arp one
  111. in mind if it doesn't work.  I also use the arp Rename command as a general
  112. rule.
  113.  
  114. In clever SmartDOS, that'd be:
  115.  
  116. List >Ram:x1 XXX: nohead quick lformat "execute Ram:x2 %s %s"
  117.  
  118. Echo >Ram:x2 ".k path,name*nLHA x XXX:<path><name>*nLZX -3 -m -r -x -e -Y a
  119. <name> #?*ncopy #?.LHA.LZX YYY:#?.LZX*n delete #? all"
  120.  
  121.   Basically, once you get it going for one operation, you just keep a Master
  122. kicking around somewhere, and when you want to do something different in the
  123. future, just plug in the different pathnames and commands.  I just used one
  124. the other day where I had it Executing a FakeKey/MovePointer file in each go-
  125. around, converting my file descriptions to file_id.diz files, pretty cool.
  126.  
  127.   - TBM
  128.  
  129.